# 无向图的顶点
class Vertex:
    def __init__(self, quadtree_node):
        self.qtree_node = quadtree_node
        self.id = (self.qtree_node.boundary.x, self.qtree_node.boundary.y)
        # P.S 关于精度：因为我们的最小网格的精度是0.01度乘以0.01度，所以计算中心坐标时，需要至少精确到小数点后三位。
        self.center = (round(self.qtree_node.boundary.x + self.qtree_node.boundary.width/2, 3),
                       round(self.qtree_node.boundary.y + self.qtree_node.boundary.height/2, 3))


# 无向图的边
class Edge:
    def __init__(self, vertex1, vertex2):
        self.v1 = vertex1
        self.v2 = vertex2
        self.weight = self._calc_weight()

    def _calc_weight(self):
        return abs(round(2 * (self.v1.center[0] - self.v2.center[0]) * 1.414, 3))  # 正边形的边长乘以1.414，得到对角线长度近似值。
